package com.gitee.feizns.quickstart.dict.spring.boot.autoconfigure.db.mybatis.plus.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.gitee.feizns.quickstart.dict.Entry;
import com.gitee.feizns.quickstart.dict.spring.boot.autoconfigure.db.mybatis.plus.pojo.QkDict;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;

import javax.persistence.Entity;
import java.util.List;

/**
 * qk dict 映射器
 * @author feizns
 * @since 2024/12/20
 */
@Mapper
@ConditionalOnClass({Entity.class, Model.class})
public interface QkDictMapper extends BaseMapper<QkDict> {

    /**
     * 查找全部
     * @return {@link List}<{@link Entry}>
     */
    static List<QkDict> findAll() {
        return new QkDict().selectList(Wrappers.query());
    }

    /**
     * 按键查找
     * @param key 钥匙
     * @return {@link QkDict}
     */
    static QkDict findByKey(String key) {
        return new QkDict().selectOne(Wrappers.<QkDict>query().lambda().eq(QkDict::getKey, key));
    }

}
